package com.atguigu.lease.common.sms;

import com.aliyun.dysmsapi20170525.Client;
import com.aliyun.teaopenapi.models.Config;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/*
 * aliyun的配置类
 * */
@Configuration
public class AliyunSMSConfiguration {
    @Autowired
    AliyunSMSProperties aliyunSMSProperties;

    @Bean
    public Client client() {
        try {
            Config config = new Config();
            config.setAccessKeyId(aliyunSMSProperties.getAccessKeyId());
            config.setAccessKeySecret(aliyunSMSProperties.getAccessKeySecret());
            config.setEndpoint(aliyunSMSProperties.getEndpoint());
            return new Client(config);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }


}
